# 用户模块的蓝图，包括用户模块的所有资源

from flask import Blueprint
from flask_restful import Api
from comment.utils.output import output_json

user_bp = Blueprint('users', __name__, url_prefix='/user')  # 创建蓝图
user_api = Api(user_bp)  # 创建资源的api对象，资源是指蓝图

user_api.representation('application/json')(output_json)  # 这句代码替代了原本装饰器的作用。看flask文档的装饰器。装饰器装饰以后，使得在调
# 用output_json这个函数输出结果时，调用我们做过修改后的这个output_json函数

from shopping.resource.user.user_resource import User_Resource, User_SMS, AuthorizationCodeResource, \
    UserRegisterResource, UserLoginResource, IsExistPhoneResource, UserLogoutResource

user_api.add_resource(User_Resource, '/hello', endpoint='user')  # endpoint是名字,可以写也可以不写
user_api.add_resource(User_SMS, '/sms', endpoint='sms')
user_api.add_resource(AuthorizationCodeResource, '/authorization', endpoint='authorization')
user_api.add_resource(UserRegisterResource, '/register', endpoint='register')
user_api.add_resource(UserLoginResource, '/login', endpoint='login')
user_api.add_resource(UserLogoutResource, '/logOut', endpoint='logout')
user_api.add_resource(IsExistPhoneResource, '/isExist', endpoint='isExist')
